Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
Getting "Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'data')"

Screenshot of error, while console in google. That's the code I gave, and getting an unexpected error

const [email, setEmail] = useState("");
    const [password, setPassword] = useState("");
    const [error, setError] = useState(false);
    const [loading, setLoading] = useState(false);

    // useEffect(() => {
    //     const userInfo = localStorage.getItem("userInfo");

    //     if(userInfo){
    //         history.push("/mynotes");
    //     }
    // }, [history]);

    const submitHandler = async (e) => {
        e.preventDefault();
        console.log(email, password);

        try{
            const config = {
                headers: {
                    "Content-type": "application/json",
                },
            }; 
            setLoading(true);

            const { data } = await axios.post(
                "/api/users/login", 
                {
                    email, 
                    password
                },
                config
            );
            
            console.log(data);

            localStorage.setItem("userInfo", JSON.stringify(data));

            setLoading(false);
        }
        catch (error){
            setError(error.response.data.message);
        //     setLoading(false);
        }
[1]: https://i.stack.imgur.com/UVse7.jpg
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!